import React, { Component } from "react";
import Modal from "./Modal";

// 这是我们自己的组件
class App extends Component {
  state = {
    show: false,
  };

  open = () => {
    this.setState({
      show: true,
    });
  };

  close = () => {
    this.setState({
      show: false,
    });
  };

  confirm = () => {
    alert("提交成功");
    this.setState({
      show: false,
    });
  };

  render() {
    return (
      <div className="box">
        <h2>modal对话框的封装</h2>
        <button onClick={this.open}>打开对话框</button>
        {/* {this.state.show && <Modal />} */}
        <Modal
          title="Basic Modal"
          open={this.state.show}
          onCancel={this.close}
          onOk={this.confirm}
          cancelText="关闭"
          okText="提交"
        >
          <p>Some contents...</p>
          <p>Some contents...</p>
          <p>Some contents...</p>
        </Modal>
      </div>
    );
  }
}

export default App;
